home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / s_saver / ssaver.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  3.6 KB  |  139 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "VB Screen Saver"
  4.    ClientHeight    =   1875
  5.    ClientLeft      =   1860
  6.    ClientTop       =   2085
  7.    ClientWidth     =   3990
  8.    FontBold        =   0   'False
  9.    FontItalic      =   0   'False
  10.    FontName        =   "MS Sans Serif"
  11.    FontSize        =   8.25
  12.    FontStrikethru  =   0   'False
  13.    FontUnderline   =   0   'False
  14.    Height          =   2280
  15.    Icon            =   SSAVER.FRX:0000
  16.    Left            =   1800
  17.    LinkMode        =   1  'Source
  18.    LinkTopic       =   "Form1"
  19.    MaxButton       =   0   'False
  20.    ScaleHeight     =   125
  21.    ScaleMode       =   3  'Pixel
  22.    ScaleWidth      =   266
  23.    Top             =   1740
  24.    Width           =   4110
  25.    Begin CommandButton Command2 
  26.       Caption         =   "Exit"
  27.       Height          =   495
  28.       Left            =   2160
  29.       TabIndex        =   3
  30.       Top             =   1080
  31.       Width           =   1215
  32.    End
  33.    Begin CommandButton Command1 
  34.       Caption         =   "Ok"
  35.       Default         =   -1  'True
  36.       Height          =   495
  37.       Left            =   480
  38.       TabIndex        =   2
  39.       Top             =   1080
  40.       Width           =   1215
  41.    End
  42.    Begin TextBox Text1 
  43.       Height          =   375
  44.       Left            =   2280
  45.       TabIndex        =   1
  46.       Top             =   360
  47.       Width           =   735
  48.    End
  49.    Begin Timer Timer1 
  50.       Interval        =   1000
  51.       Left            =   120
  52.       Top             =   120
  53.    End
  54.    Begin Label Label1 
  55.       Caption         =   "Seconds:"
  56.       Height          =   255
  57.       Left            =   1080
  58.       TabIndex        =   0
  59.       Top             =   480
  60.       Width           =   855
  61.    End
  62. DefInt A-Z
  63. Declare Function RegisterSSaver Lib "ssave.dll" (ByVal hWnd, ByVal VKCode)
  64. Declare Sub UnRegisterSSaver Lib "ssave.dll" (ByVal hWnd)
  65. Dim Saving, SecondsLeft, Seconds2Wait, Resizing
  66. Sub Command1_Click ()
  67.     Seconds2Wait = Val(Text1.Text)
  68.     SecondsLeft = Seconds2Wait
  69.     WindowState = 1
  70.     ShowTime
  71. End Sub
  72. Sub Command2_Click ()
  73.     Unload Form1
  74. End Sub
  75. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  76.     If Resizing Then
  77.         Resizing = False
  78.         Exit Sub
  79.     End If
  80.     If KeyCode = 301 Then
  81.         SecondsLeft = Seconds2Wait
  82.         If Saving Then
  83.             RestoreScreen
  84.             ShowTime
  85.             Saving = False
  86.         End If
  87.     End If
  88. End Sub
  89. Sub Form_Load ()
  90.     WindowState = 1
  91.     Caption = "ScrnSave - " + Format$(Now, "m/d")
  92.     If RegisterSSaver(hWnd, 301) Then
  93.         Saving = False
  94.         Seconds2Wait = 60 '1 minute
  95.         SecondsLeft = Seconds2Wait
  96.     Else
  97.         MsgBox "Unable to install!"
  98.         Unload Form1
  99.     End If
  100. End Sub
  101. Sub Form_Unload (Cancel As Integer)
  102.     Unload Palette
  103.     UnRegisterSSaver hWnd
  104.     End
  105. End Sub
  106. Sub RestoreScreen ()
  107.     Palette.Visible = False
  108.     Timer1.Enabled = True
  109. End Sub
  110. Sub SaveScreen ()
  111.     Timer1.Enabled = False
  112.     Resizing = True
  113.     Palette.Show
  114. End Sub
  115. Sub ShowTime ()
  116.     Refresh
  117.     If WindowState = 1 Then
  118.         Capt$ = Format$(Now, "HH:MM")
  119.         CurrentX = 5
  120.         CurrentY = 11
  121.         Print Capt$
  122.     End If
  123. End Sub
  124. Sub Timer1_Timer ()
  125.     Static Ticks
  126.     SecondsLeft = SecondsLeft - 1
  127.     If (SecondsLeft < 1) And (Saving = False) Then
  128.         'Start Screen saving here!
  129.         Saving = True
  130.         SaveScreen
  131.     Else
  132.         Ticks = Ticks + 1
  133.         If Ticks > 20 Then
  134.             ShowTime
  135.             Ticks = 0
  136.         End If
  137.     End If
  138. End Sub
  139.